define([
  'text!templates/home/mainDashboard.html',
  'models/crud/solutionModel',
  'models/crud/projectModel',
], function (DashTemplate,  SolutionModel, ProjectModel) {

    var View = Backbone.View.extend({
        el: $("#main-content"),
        render: function () {
            toggleLoading(true);
            var that = this;
            changeTopNavTitle("_dashboard");
            // Prepare Main Template
            var dashTempl = Handlebars.compile(DashTemplate);

            (new SolutionModel()).list(__currentSession.userId, function (solutions) {
                // To DO: usar listLast en vez de list, para pasarle la cantidad de semanas
                // de tiempo de edicion maximo que quiero que traiga.

                //var data = {
                //    userName: __currentSession.userName,
                //    companyName: __currentSession.companyName
                //};

                //var html = dashTempl(solutions);
                //var html = dashTempl();

                that.$el.html(dashTempl(solutions));
                that.addHandlers();
                toggleLoading(false);
                ////this.$el.append(menuHTML);
            });
            
            

        },
        showProject: function () {
            
        },
        addHandlers: function () {
            this.$el.find(".solution_card li").on("click", function () {
                var projId = +$(this).attr("data-id");
                require(['controllers/crud/projectMngr'], function (Controller) {
                    (new Controller()).showEdit($("#main-content"), projId);
                });
            });

            //$.each(this.$el.find(".solution_card"), function () {
            //    $(this)
            //});
        }
    });
    return View;
});
